﻿using Common;
using NewDevice;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CarPCBATest.Procedure
{
    public class ZhiContrl : SerialBase
    {
        public ZhiContrl(string deviceName = "开短路检测仪") : base()
        {
        }

        public bool Test()
        {
            byte[] bytes = { 0x01, 0x05, 0x00, 0x10, 0xFF, 0x00, 0x8D, 0xFF };
            var receivedString = Encoding.ASCII.GetString(SendBytesAndWaitResponse(bytes, ResultBytesVerify, 3000));
            Mylog.DeviceData(deviceName: deviceName, receivedData: receivedString);
            return receivedString.Contains("PASS");
        }

        private bool ResultBytesVerify(byte[] data)
        {
            var stringData = Encoding.ASCII.GetString(data); ;
            return (stringData.Contains("PASS") || stringData.Contains("FAIL"));
        }
    }
}